package com.gpnu.crm.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.gpnu.crm.domain.SystemDictionaryItem;
import com.gpnu.crm.query.SystemDictionaryQueryObject;
import com.gpnu.crm.service.ISystemDictionaryService;


@Controller
@RequestMapping("/systemDictionaryItem")
public class SystemDictionaryItemController {
	@Autowired
	private ISystemDictionaryService systemDictionaryService;

	@RequestMapping("/list")
	public String list(@ModelAttribute("qo") SystemDictionaryQueryObject  qo, Model model) {
	    model.addAttribute("dictionaries", systemDictionaryService.list());
	    if (qo.getParentId().longValue() > 0L) {
	      qo.setOrderby("sequence desc");
	      model.addAttribute("pageInfo", systemDictionaryService.queryItem(qo));
	    }
	    return "systemDictionaryItem/list";
	}

	@RequestMapping("/saveOrUpdate")
	public String saveOrUpdate(SystemDictionaryItem e){
		systemDictionaryService.saveOrUpdateItem(e);
		return "redirect:/systemDictionary/list.do";
	}


}
